	clear all
	set more off
	set maxvar 20000

	
	use "$data/choice_data.dta", clear
	
	
	keep ID toy_A_B-toy_E_F
	
	compress
		
	// keeping only children that made all 15 choices in toys task
	foreach choice in 	A_B A_C A_D A_E A_F B_C B_D B_E B_F C_D C_E C_F D_E D_F E_F {
		drop if toy_`choice' >= .
	}

	label drop toys
	label define toys 	///
	1 "A" 			///
	2 "B" 		///
	3 "C" 		///
	4 "D" 			///
	5 "E" 		///
	6 "F" 			///
	7 "Indifferent"	
	
	// using labels to transform from numeric to string variable
	foreach choice in 	A_B A_C A_D A_E A_F B_C B_D B_E B_F C_D C_E C_F D_E D_F E_F {
		decode toy_`choice', gen(choice_`choice')
	}
	
	******************************************************
	******************************************************

	// program calculates total number of violations for given set of trios
	
	capture program drop violations
	program define violations
	
		gen `1' = 0
	
		foreach trio in `2' {
			
			local option1 = substr("`trio'",1,1)			
			local option2 = substr("`trio'",3,1)
			local option3 = substr("`trio'",5,1)
			
		
			// no indifferences
			replace `1' = `1' + 1			if (choice_`option1'_`option2' == "`option1'" 		& choice_`option2'_`option3' == "`option2'"			& choice_`option1'_`option3' == "`option3'") 
			replace `1' = `1' + 1			if (choice_`option1'_`option2' == "`option2'" 		& choice_`option2'_`option3' == "`option3'"			& choice_`option1'_`option3' == "`option1'") 
			
			
			// one indifference
			replace `1' = `1' + $weight  	if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "`option3'"			& choice_`option1'_`option3' == "`option1'") 
			replace `1' = `1' + $weight  	if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "`option2'"			& choice_`option1'_`option3' == "`option3'") 
			
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option1'" 		& choice_`option2'_`option3' == "`option2'"			& choice_`option1'_`option3' == "Indifferent") 
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option2'" 		& choice_`option2'_`option3' == "`option3'"			& choice_`option1'_`option3' == "Indifferent") 
		
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option1'" 		& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "`option3'") 
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option2'" 		& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "`option1'") 

			
			// two indifferences
			replace `1' = `1' + $weight  	if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "`option1'") 
			replace `1' = `1' + $weight  	if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "`option3'") 
			
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "`option2'"			& choice_`option1'_`option3' == "Indifferent") 
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "Indifferent" 	& choice_`option2'_`option3' == "`option3'"			& choice_`option1'_`option3' == "Indifferent") 
		
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option1'" 		& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "Indifferent") 
			replace `1' = `1' + $weight		if (choice_`option1'_`option2' == "`option2'" 		& choice_`option2'_`option3' == "Indifferent"		& choice_`option1'_`option3' == "Indifferent") 

		}			
			
	end
	

	******************************************************
	
	global weight .5 // weight assigned to trio including at least one indifference

	******************************************************
	
	// creating a list with all possible decisions

	local all_options "A B C D E F"
	

	local all_decisions ""
	
	forvalues i = 1/5 {
		
		local option1 : word `i' of `all_options'
		
		local j = `i' + 1
		
		forvalues k = `j'/6 {
			
			local option2 : word `k' of `all_options'
			
			local all_decisions "`all_decisions' `option1'_`option2'"
						
		}
		
	}	
	
	local n_decisions : word count `all_decisions'
	
	******************************************************
	
	// creating a list with all possible trios
	

	local all_trios ""
	
	forvalues i = 1/4 {
		
		local option1 : word `i' of `all_options'
		
		local j = `i' + 1
		
		forvalues k = `j'/5 {
			
			local option2 : word `k' of `all_options'
			
			local l = `k' + 1
			
			forvalues m = `l'/6 {
				
				local option3 : word `m' of `all_options'
				
				local all_trios "`all_trios' `option1'_`option2'_`option3'"

			}
			
		}
		
	}	
	
	local n_trios : word count `all_trios'
	
	******************************************************
	
	// number of violations when including all 15 choices
	
	qui violations Nviolations_15choices "`all_trios'"
	
	preserve
	
		keep if Nviolations_15choices == 0
		
		keep ID Nviolations_15choices
	
		gen HM = 15
	
		tempfile sample1
		
		save `sample1'
	
	restore
		
	drop if Nviolations_15choices == 0
	
	count
	
	
	preserve
	
		keep ID Nviolations_15choices
	
		tempfile sample2
		
		save `sample2'
	
	restore
	
	******************************************************	
	
	// number of violations when excluding 1 choice
	
	
	forvalues i = 1/`n_decisions' {
	
		local decision_to_drop : word `i' of `all_decisions'
		
		local option1 = substr("`decision_to_drop'",1,1)
		
		local option2 = substr("`decision_to_drop'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options: list all_options - option1_option2
		
		local trios_to_drop ""
		
		forvalues j = 1/4 {
			
			local option3 : word `j' of `other_options'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop "`trios_to_drop' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop "`trios_to_drop' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop "`trios_to_drop' `option1'_`option2'_`option3'"
						
			}
			
		}
		
		local trios: list all_trios - trios_to_drop
		
		qui violations temp "`trios'"
		
		qui drop if  temp == 0
		
		qui drop temp
		
	}
		
	preserve
	
		keep ID
	
		tempfile sample3
		
		save `sample3'
	
	restore
	
	******************************************************	
	
	// number of violations when excluding 2 choices
	
	local n_decisions_m1 = `n_decisions' - 1	
	
	
	forvalues i1 = 1/`n_decisions' {
	
		local decision_to_drop1 : word `i1' of `all_decisions'
		
		local option1 = substr("`decision_to_drop1'",1,1)
		
		local option2 = substr("`decision_to_drop1'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options1: list all_options - option1_option2
		
		local trios_to_drop1 ""
		
		forvalues j1 = 1/4 {
			
			local option3 : word `j1' of `other_options1'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option2'_`option3'"
						
			}
			
		}
		

		local other_decisions1: list all_decisions - decision_to_drop1
		
		forvalues i2 = 1/`n_decisions_m1' {		
		
			local decision_to_drop2 : word `i2' of `other_decisions1'
		
			local option4 = substr("`decision_to_drop2'",1,1)
		
			local option5 = substr("`decision_to_drop2'",3,1)
		
			local option4_option5 "`option4' `option5'" 
	
			local other_options2: list all_options - option4_option5

		
			local trios_to_drop2 ""
		
			forvalues j2 = 1/4 {
				
				local option6 : word `j2' of `other_options2'
				
				
				if "`option6'" < "`option4'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option6'_`option4'_`option5'"
							
				}
				
				
				if "`option6'" > "`option4'" & "`option6'" < "`option5'"  {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option6'_`option5'"
							
				}
			
				if "`option6'" > "`option5'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option5'_`option6'"
							
				}
				
			}
			
			local trios: list all_trios - trios_to_drop1
			
			local trios: list trios - trios_to_drop2
			
				
			
			qui violations temp "`trios'"
			
			qui drop if temp == 0
			
			qui drop temp
			
			
		}
		
	}
		
	preserve
	
		keep ID
	
		tempfile sample4
		
		save `sample4'
	
	restore

	******************************************************	
	
	// number of violations when excluding 3 choices
	
	local n_decisions_m2 = `n_decisions' - 2	
	
	
	forvalues i1 = 1/`n_decisions' {
	
		local decision_to_drop1 : word `i1' of `all_decisions'
		
		local option1 = substr("`decision_to_drop1'",1,1)
		
		local option2 = substr("`decision_to_drop1'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options1: list all_options - option1_option2
		
		local trios_to_drop1 ""
		
		forvalues j1 = 1/4 {
			
			local option3 : word `j1' of `other_options1'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option2'_`option3'"
						
			}
			
		}
		

		local other_decisions1: list all_decisions - decision_to_drop1
		
		forvalues i2 = 1/`n_decisions_m1' {		
		
			local decision_to_drop2 : word `i2' of `other_decisions1'
		
			local option4 = substr("`decision_to_drop2'",1,1)
		
			local option5 = substr("`decision_to_drop2'",3,1)
		
			local option4_option5 "`option4' `option5'" 
	
			local other_options2: list all_options - option4_option5

		
			local trios_to_drop2 ""
		
			forvalues j2 = 1/4 {
				
				local option6 : word `j2' of `other_options2'
				
				
				if "`option6'" < "`option4'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option6'_`option4'_`option5'"
							
				}
				
				
				if "`option6'" > "`option4'" & "`option6'" < "`option5'"  {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option6'_`option5'"
							
				}
			
				if "`option6'" > "`option5'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option5'_`option6'"
							
				}
				
			}
			
			local other_decisions2: list other_decisions1 - decision_to_drop2
			
			forvalues i3 = 1/`n_decisions_m2' {		
			
				local decision_to_drop3 : word `i3' of `other_decisions2'
			
				local option7 = substr("`decision_to_drop3'",1,1)
			
				local option8 = substr("`decision_to_drop3'",3,1)
			
				local option7_option8 "`option7' `option8'" 
		
				local other_options3: list all_options - option7_option8

			
				local trios_to_drop3 ""
			
				forvalues j3 = 1/4 {
					
					local option6 : word `j3' of `other_options3'
					
					
					if "`option9'" < "`option7'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option9'_`option7'_`option8'"
								
					}
					
					
					if "`option9'" > "`option7'" & "`option9'" < "`option8'"  {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option9'_`option8'"
								
					}
				
					if "`option9'" > "`option8'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option8'_`option9'"
								
					}
					
				}
				
				local trios: list all_trios - trios_to_drop1
			
				local trios: list trios - trios_to_drop2
				
				local trios: list trios - trios_to_drop3
				
				
				
				qui violations temp "`trios'"
				
				qui drop if temp == 0
				
				qui drop temp
				
				
			}
						
		}
		
	}
		
	preserve
	
		keep ID
	
		tempfile sample5
		
		save `sample5'
	
	restore
		
	
	******************************************************	
	
	// number of violations when excluding 4 choices
	
	local n_decisions_m3 = `n_decisions' - 3	
	
	
	forvalues i1 = 1/`n_decisions' {
	
		local decision_to_drop1 : word `i1' of `all_decisions'
		
		local option1 = substr("`decision_to_drop1'",1,1)
		
		local option2 = substr("`decision_to_drop1'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options1: list all_options - option1_option2
		
		local trios_to_drop1 ""
		
		forvalues j1 = 1/4 {
			
			local option3 : word `j1' of `other_options1'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option2'_`option3'"
						
			}
			
		}
		

		local other_decisions1: list all_decisions - decision_to_drop1
		
		forvalues i2 = 1/`n_decisions_m1' {		
		
			local decision_to_drop2 : word `i2' of `other_decisions1'
		
			local option4 = substr("`decision_to_drop2'",1,1)
		
			local option5 = substr("`decision_to_drop2'",3,1)
		
			local option4_option5 "`option4' `option5'" 
	
			local other_options2: list all_options - option4_option5

		
			local trios_to_drop2 ""
		
			forvalues j2 = 1/4 {
				
				local option6 : word `j2' of `other_options2'
				
				
				if "`option6'" < "`option4'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option6'_`option4'_`option5'"
							
				}
				
				
				if "`option6'" > "`option4'" & "`option6'" < "`option5'"  {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option6'_`option5'"
							
				}
			
				if "`option6'" > "`option5'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option5'_`option6'"
							
				}
				
			}
			
			local other_decisions2: list other_decisions1 - decision_to_drop2
			
			forvalues i3 = 1/`n_decisions_m2' {		
			
				local decision_to_drop3 : word `i3' of `other_decisions2'
			
				local option7 = substr("`decision_to_drop3'",1,1)
			
				local option8 = substr("`decision_to_drop3'",3,1)
			
				local option7_option8 "`option7' `option8'" 
		
				local other_options3: list all_options - option7_option8

			
				local trios_to_drop3 ""
			
				forvalues j3 = 1/4 {
					
					local option9 : word `j3' of `other_options3'
					
					
					if "`option9'" < "`option7'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option9'_`option7'_`option8'"
								
					}
					
					
					if "`option9'" > "`option7'" & "`option9'" < "`option8'"  {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option9'_`option8'"
								
					}
				
					if "`option9'" > "`option8'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option8'_`option9'"
								
					}
					
				}
				
				
				local other_decisions3: list other_decisions2 - decision_to_drop3
			
				forvalues i4 = 1/`n_decisions_m3' {		
			
					local decision_to_drop4 : word `i4' of `other_decisions3'
				
					local option10 = substr("`decision_to_drop4'",1,1)
				
					local option11 = substr("`decision_to_drop4'",3,1)
				
					local option10_option11 "`option10' `option11'" 
			
					local other_options4: list all_options - option10_option11

				
					local trios_to_drop4 ""
				
					forvalues j4 = 1/4 {
						
						local option12 : word `j4' of `other_options4'
						
						
						if "`option12'" < "`option10'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option12'_`option10'_`option11'"
									
						}
						
						
						if "`option12'" > "`option10'" & "`option12'" < "`option11'"  {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option12'_`option11'"
									
						}
					
						if "`option12'" > "`option11'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option11'_`option12'"
									
						}
						
					}
	
	
					local trios: list all_trios - trios_to_drop1
				
					local trios: list trios - trios_to_drop2
					
					local trios: list trios - trios_to_drop3
					
					local trios: list trios - trios_to_drop4
					
					
					
					qui violations temp "`trios'"
					
					qui drop if temp == 0
					
					qui drop temp

				
				}				
				
			}
						
		}
		
	}
		
	
	preserve
	
		keep ID
	
		tempfile sample6
		
		save `sample6'
	
	restore		
	
	
	******************************************************	
	
	// number of violations when excluding 5 choices
	
	local n_decisions_m4 = `n_decisions' - 4	
	
	
	forvalues i1 = 1/`n_decisions' {
	
		local decision_to_drop1 : word `i1' of `all_decisions'
		
		local option1 = substr("`decision_to_drop1'",1,1)
		
		local option2 = substr("`decision_to_drop1'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options1: list all_options - option1_option2
		
		local trios_to_drop1 ""
		
		forvalues j1 = 1/4 {
			
			local option3 : word `j1' of `other_options1'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option2'_`option3'"
						
			}
			
		}
		

		local other_decisions1: list all_decisions - decision_to_drop1
		
		forvalues i2 = 1/`n_decisions_m1' {		
		
			local decision_to_drop2 : word `i2' of `other_decisions1'
		
			local option4 = substr("`decision_to_drop2'",1,1)
		
			local option5 = substr("`decision_to_drop2'",3,1)
		
			local option4_option5 "`option4' `option5'" 
	
			local other_options2: list all_options - option4_option5

		
			local trios_to_drop2 ""
		
			forvalues j2 = 1/4 {
				
				local option6 : word `j2' of `other_options2'
				
				
				if "`option6'" < "`option4'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option6'_`option4'_`option5'"
							
				}
				
				
				if "`option6'" > "`option4'" & "`option6'" < "`option5'"  {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option6'_`option5'"
							
				}
			
				if "`option6'" > "`option5'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option5'_`option6'"
							
				}
				
			}
			
			local other_decisions2: list other_decisions1 - decision_to_drop2
			
			forvalues i3 = 1/`n_decisions_m2' {		
			
				local decision_to_drop3 : word `i3' of `other_decisions2'
			
				local option7 = substr("`decision_to_drop3'",1,1)
			
				local option8 = substr("`decision_to_drop3'",3,1)
			
				local option7_option8 "`option7' `option8'" 
		
				local other_options3: list all_options - option7_option8

			
				local trios_to_drop3 ""
			
				forvalues j3 = 1/4 {
					
					local option9 : word `j3' of `other_options3'
					
					
					if "`option9'" < "`option7'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option9'_`option7'_`option8'"
								
					}
					
					
					if "`option9'" > "`option7'" & "`option9'" < "`option8'"  {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option9'_`option8'"
								
					}
				
					if "`option9'" > "`option8'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option8'_`option9'"
								
					}
					
				}
				
				
				local other_decisions3: list other_decisions2 - decision_to_drop3
			
				forvalues i4 = 1/`n_decisions_m3' {		
			
					local decision_to_drop4 : word `i4' of `other_decisions3'
				
					local option10 = substr("`decision_to_drop4'",1,1)
				
					local option11 = substr("`decision_to_drop4'",3,1)
				
					local option10_option11 "`option10' `option11'" 
			
					local other_options4: list all_options - option10_option11

				
					local trios_to_drop4 ""
				
					forvalues j4 = 1/4 {
						
						local option12 : word `j4' of `other_options4'
						
						
						if "`option12'" < "`option10'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option12'_`option10'_`option11'"
									
						}
						
						
						if "`option12'" > "`option10'" & "`option12'" < "`option11'"  {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option12'_`option11'"
									
						}
					
						if "`option12'" > "`option11'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option11'_`option12'"
									
						}
						
					}
	
		
					local other_decisions4: list other_decisions3 - decision_to_drop4
				
					forvalues i5 = 1/`n_decisions_m4' {		
				
						local decision_to_drop5 : word `i5' of `other_decisions4'
					
						local option13 = substr("`decision_to_drop5'",1,1)
					
						local option14 = substr("`decision_to_drop5'",3,1)
					
						local option13_option14 "`option13' `option14'" 
				
						local other_options5: list all_options - option13_option14

					
						local trios_to_drop5 ""
					
						forvalues j5 = 1/4 {
							
							local option15 : word `j5' of `other_options5'
							
							
							if "`option15'" < "`option13'" {
								
								local trios_to_drop5 "`trios_to_drop5' `option15'_`option13'_`option14'"
										
							}
							
							
							if "`option15'" > "`option13'" & "`option15'" < "`option14'"  {
								
								local trios_to_drop5 "`trios_to_drop5' `option13'_`option15'_`option14'"
										
							}
						
							if "`option15'" > "`option14'" {
								
								local trios_to_drop5 "`trios_to_drop5' `option13'_`option14'_`option15'"
										
							}
							
						}
		
						local trios: list all_trios - trios_to_drop1
					
						local trios: list trios - trios_to_drop2
						
						local trios: list trios - trios_to_drop3
						
						local trios: list trios - trios_to_drop4
						
						local trios: list trios - trios_to_drop5
						
						
						
						qui violations temp "`trios'"
						
						qui drop if temp == 0
						
						qui drop temp
					
					}

				}				
				
			}
						
		}
		
	}
		
	preserve

		keep ID
	
		tempfile sample7
		
		save `sample7'
	
	restore		
	
	
	count
	
	
	******************************************************	
	/*
	// number of violations when excluding 6 choices
	
	local n_decisions_m5 = `n_decisions' - 5	
	
	
	forvalues i1 = 1/`n_decisions' {
	
		local decision_to_drop1 : word `i1' of `all_decisions'
		
		local option1 = substr("`decision_to_drop1'",1,1)
		
		local option2 = substr("`decision_to_drop1'",3,1)
		
		local option1_option2 "`option1' `option2'" 
	
		local other_options1: list all_options - option1_option2
		
		local trios_to_drop1 ""
		
		forvalues j1 = 1/4 {
			
			local option3 : word `j1' of `other_options1'
			
			
			if "`option3'" < "`option1'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option3'_`option1'_`option2'"
						
			}
			
			
			if "`option3'" > "`option1'" & "`option3'" < "`option2'"  {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option3'_`option2'"
						
			}
		
			if "`option3'" > "`option2'" {
				
				local trios_to_drop1 "`trios_to_drop1' `option1'_`option2'_`option3'"
						
			}
			
		}
		

		local other_decisions1: list all_decisions - decision_to_drop1
		
		forvalues i2 = 1/`n_decisions_m1' {		
		
			local decision_to_drop2 : word `i2' of `other_decisions1'
		
			local option4 = substr("`decision_to_drop2'",1,1)
		
			local option5 = substr("`decision_to_drop2'",3,1)
		
			local option4_option5 "`option4' `option5'" 
	
			local other_options2: list all_options - option4_option5

		
			local trios_to_drop2 ""
		
			forvalues j2 = 1/4 {
				
				local option6 : word `j2' of `other_options2'
				
				
				if "`option6'" < "`option4'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option6'_`option4'_`option5'"
							
				}
				
				
				if "`option6'" > "`option4'" & "`option6'" < "`option5'"  {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option6'_`option5'"
							
				}
			
				if "`option6'" > "`option5'" {
					
					local trios_to_drop2 "`trios_to_drop2' `option4'_`option5'_`option6'"
							
				}
				
			}
			
			local other_decisions2: list other_decisions1 - decision_to_drop2
			
			forvalues i3 = 1/`n_decisions_m2' {		
			
				local decision_to_drop3 : word `i3' of `other_decisions2'
			
				local option7 = substr("`decision_to_drop3'",1,1)
			
				local option8 = substr("`decision_to_drop3'",3,1)
			
				local option7_option8 "`option7' `option8'" 
		
				local other_options3: list all_options - option7_option8

			
				local trios_to_drop3 ""
			
				forvalues j3 = 1/4 {
					
					local option9 : word `j3' of `other_options3'
					
					
					if "`option9'" < "`option7'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option9'_`option7'_`option8'"
								
					}
					
					
					if "`option9'" > "`option7'" & "`option9'" < "`option8'"  {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option9'_`option8'"
								
					}
				
					if "`option9'" > "`option8'" {
						
						local trios_to_drop3 "`trios_to_drop3' `option7'_`option8'_`option9'"
								
					}
					
				}
				
				
				local other_decisions3: list other_decisions2 - decision_to_drop3
			
				forvalues i4 = 1/`n_decisions_m3' {		
			
					local decision_to_drop4 : word `i4' of `other_decisions3'
				
					local option10 = substr("`decision_to_drop4'",1,1)
				
					local option11 = substr("`decision_to_drop4'",3,1)
				
					local option10_option11 "`option10' `option11'" 
			
					local other_options4: list all_options - option10_option11

				
					local trios_to_drop4 ""
				
					forvalues j4 = 1/4 {
						
						local option12 : word `j4' of `other_options4'
						
						
						if "`option12'" < "`option10'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option12'_`option10'_`option11'"
									
						}
						
						
						if "`option12'" > "`option10'" & "`option12'" < "`option11'"  {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option12'_`option11'"
									
						}
					
						if "`option12'" > "`option11'" {
							
							local trios_to_drop4 "`trios_to_drop4' `option10'_`option11'_`option12'"
									
						}
						
					}
	
		
					local other_decisions4: list other_decisions3 - decision_to_drop4
				
					forvalues i5 = 1/`n_decisions_m4' {		
				
						local decision_to_drop5 : word `i5' of `other_decisions4'
					
						local option13 = substr("`decision_to_drop5'",1,1)
					
						local option14 = substr("`decision_to_drop5'",3,1)
					
						local option13_option14 "`option13' `option14'" 
				
						local other_options5: list all_options - option13_option14

					
						local trios_to_drop5 ""
					
						forvalues j5 = 1/4 {
							
							local option15 : word `j5' of `other_options5'
							
							
							if "`option15'" < "`option13'" {
								
								local trios_to_drop5 "`trios_to_drop5' `option15'_`option13'_`option14'"
										
							}
							
							
							if "`option15'" > "`option13'" & "`option15'" < "`option14'"  {
								
								local trios_to_drop5 "`trios_to_drop5' `option13'_`option15'_`option14'"
										
							}
						
							if "`option15'" > "`option14'" {
								
								local trios_to_drop5 "`trios_to_drop5' `option13'_`option14'_`option15'"
										
							}
							
						}
		
						local other_decisions5: list other_decisions4 - decision_to_drop5
					
						forvalues i6 = 1/`n_decisions_m5' {		
					
							local decision_to_drop6 : word `i6' of `other_decisions5'
						
							local option16 = substr("`decision_to_drop6'",1,1)
						
							local option17 = substr("`decision_to_drop6'",3,1)
						
							local option16_option17 "`option16' `option17'" 
					
							local other_options6: list all_options - option16_option17

						
							local trios_to_drop6 ""
						
							forvalues j6 = 1/4 {
								
								local option18 : word `j6' of `other_options6'
								
								
								if "`option18'" < "`option16'" {
									
									local trios_to_drop6 "`trios_to_drop6' `option18'_`option16'_`option17'"
											
								}
								
								
								if "`option18'" > "`option16'" & "`option18'" < "`option17'"  {
									
									local trios_to_drop6 "`trios_to_drop6' `option16'_`option18'_`option17'"
											
								}
							
								if "`option18'" > "`option17'" {
									
									local trios_to_drop6 "`trios_to_drop6' `option16'_`option17'_`option18'"
											
								}
								
							}

						
							local trios: list all_trios - trios_to_drop1
						
							local trios: list trios - trios_to_drop2
							
							local trios: list trios - trios_to_drop3
							
							local trios: list trios - trios_to_drop4
							
							local trios: list trios - trios_to_drop5
							
							local trios: list trios - trios_to_drop6
							
							
							qui violations temp "`trios'"
							
							qui drop if temp == 0
							
							qui drop temp
							
						}
					
					}

				}				
				
			}
						
		}
		
	}
		
	preserve

		keep ID
	
		tempfile sample8
		
		save `sample8'
	
	restore		
	*/
	
	count
	
	
	use `sample2', clear	
	
	gen HM = .
	
	forvalues i = 3/7 {
		
		merge 1:1 ID using `sample`i''
		
		replace HM = 17 - `i' if _merge == 1 & HM == .
		
		drop _merge
		
	}

	append using `sample1'
	
	
	
	keep ID HM
	
	ren HM hm_toys
	
	sort ID
	save "$data/secondary/Houtman and Maks/HM_toys.dta", replace	
